<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<title>设置密码</title>
	<link rel="stylesheet" href="/front/layui/css/layui.css" />
	<link rel="stylesheet" href="/front/css/bootstrap.css" />
	<link rel="stylesheet" href="/front/css/iconfont.css" />
	<link rel="stylesheet" href="/front/css/base.css" />
	<script type="text/javascript" src="/front/js/jquery-3.3.1.min.js" ></script>
	<script src="/front/js/bootstrap.js"></script>
	<script src="/front/layui/layui.js" charset="utf-8"></script>
	<script src="/front/js/base.js" charset="utf-8"></script>
	<script src="/front/js/api.js" charset="utf-8"></script>
	<script src="/front/js/common.js" charset="utf-8"></script>
</head>
<body>
<div class="" style="margin-top: 5%;">
	<div class=" ">
		<div class="">
			<form class="layui-form" action="">
				<div class="layui-form-item">
					<label class="layui-form-label"><i class="red">*</i>旧密码：</label>
					<div class="layui-input-inline">
						<input type="password" name="oldPass" id="oldPass" required lay-verify="required" placeholder="" autocomplete="off" class="layui-input">
					</div>
					<div class="layui-form-mid layui-word-aux">请输入旧密码</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label"><i class="red">*</i>密码：</label>
					<div class="layui-input-inline">
						<input type="password" name="password" id="password" required lay-verify="required|minLength" placeholder="" autocomplete="off" class="layui-input">
					</div>
					<div class="layui-form-mid layui-word-aux">不得少于6位</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label"><i class="red">*</i>再次输入密码：</label>
					<div class="layui-input-inline">
						<input type="password" name="repassword"  id="repassword" required lay-verify="required|minLength|confirmPass" placeholder="" autocomplete="off" class="layui-input">
					</div>
					<div class="layui-form-mid layui-word-aux">不得少于6位</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label"></label>
					<div class="layui-input-block ">
						<a class="btn my-btn my-btn2" href="javascript:void(0);"onclick="resetPassword()" lay-submit="" lay-filter="resetPassword">确认</a>
						<a class="btn my-btn my-btn2 marginl20" href="javascript:void(0);" onclick="toClose()" >取消</a>
					</div>
				</div>
			</form>

		</div>
	</div>
</div>
<script type="text/javascript">

	layuiReady (function() {
		//自定义验证
		layform.verify({
			minLength:function(value){
				if(value.length < 6){
					return '密码不能少于6位';
				}
			},
			confirmPass:function(value){
				if($('input[name=password]').val() !== value){
					return '两次密码输入不一致!';
				}

			}
		});
	}, '0');

	function resetPassword() {
		var oldPass = $("#oldPass").val();
		var password = $("#password").val();
		Layui.confirm("确定提交吗？", {
                btn: ['确定', '取消']
            }, function (index) {
            noSubmit('#resetPassword');
			This.jqueryAjax(Api.enterpriseBasic.resetPassword, {newPass: password,oldPass: oldPass}, "json", function(data){
				if (data && data.status == 1) {
					closeFlushParent(parent);
					parent.parent_receive(data.message);
				} else {
					reSubmit('#resetPassword');
					layerMessage(data.message, 2);
				}
			});
        })
	}
</script>
</body>
</html>
